package Rectangle;

class Rectangle
{
    int width;
    int height;
    Rectangle(int w,int h)
    {
        if(w>50||w<0||h>50||h<0)
        {
            System.out.println("要求长和高的范围为0~50");
        }
        else
        {
            width = w;
            height = h;
        }
    }
    int getArea()
    {
        return width*height;
    }
    int getPerimeter()
    {
        return (width+height)*2;
    }
    void drawRectangle()
    {
        for(int i = 0;i<height;++i)
        {
            for(int j = 0;j<width;++j)
            {
                if(i == 0||i == height-1)
                    System.out.print("*");
                else
                {
                    if(j == 0||j == width-1)
                        System.out.print("*");
                    else
                        System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}
public class TestRectangle {
    public static void main(String[] args)
    {
        Rectangle x = new Rectangle(4,5);
        System.out.println(x.getArea());
        System.out.println(x.getPerimeter());
        x.drawRectangle();
    }
}
